package Command;

/**
 * @author duanzhizhou
 * @date 2024/11/4
 */
public class ConcretCommand extends Command{
    
    public ConcretCommand(Calculator calculator, char op, double num) {
        super(calculator, op, num);
    }
    
    @Override
    protected void Execute() {
        calculator.calc(op, num);
    }
    
    @Override
    protected void UnExecute() {
        calculator.calc(undo(op), num);
    }
    
    private char undo(char op) {
        switch (op) {
            case '+' :
                return '-';
            case '-' :
                return '+';
            case '*' :
                return '/';
            case '/' :
                return '*';
        }
        throw new RuntimeException("不支持的计算类型");
    }
}
